package cn.tedu.flowers.controller;


import cn.tedu.flowers.entity.U;
import cn.tedu.flowers.mapper.UMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UController {
    @Autowired(required = false)
    UMapper mapper;

    @RequestMapping("/check")
    public String check(String username){
        U user = mapper.selectByUsername(username);
        if (user!=null){
            return "用户名已存在";
        }
        return "用户名可用";
    }

    /*@RequestMapping("/reg")
    public int name(U u){
        U user = mapper.selectByUsername(u.getUsername());
        if (user==null){
            if (user.getPassword().length()!=0){
                if (user.getNickname().length()!=0){
                    mapper.insert(u);
                    return 0;
                }
                return 2;
            }
            return 1;
        }
        return 3;
    }*/
}
